package com.honey.compilation.sql.dml;

import com.honey.compilation.sql.SqlCommand;
import com.honey.compilation.sql.SqlKeyWord;
import com.honey.compilation.sql.ddl.SQL92Comment;
import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.compiler.CompilationException;

/**
 * 联合查询
 * @author Administrator
 *
 */
abstract class AbstractUnion extends SQL92Comment implements SqlCommand{
	
	/** UNION */
	private static final SqlKeyWord UNION_COMMAND=SqlKeyWord.UNION ;
	
	/** UNION ALL */
	private boolean unionAll = false;

	/**
	 * 是否使用union all 查询
	 * @return true:是 false 否
	 */
	public boolean isUnionAll() {
		return unionAll;
	}

	/**
	 * 是否使用union all 查询
	 * @param unionAll true:是 false 否
	 */
	public void setUnionAll(boolean unionAll) {
		this.unionAll = unionAll;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.SqlCommand#getCommand()
	 */
	@Override
	public String getCommand() {
		return UNION_COMMAND.getValue();
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.ddl.SQL92Comment#compiledContent(int)
	 */
	@Override
	public CharacterBuilder compiledContent(int indentLevel ) throws CompilationException{
		CharacterBuilder answer = CharacterBuilderFactory.createC16StringBuilder();
		answer.append(super.compiledContent(indentLevel));
//		IndentSpace.spaceIndent(answer, indentLevel);
//		answer.append(UNION_COMMAND);
//		if(unionAll){
//			answer.append(SqlKeyWord.ALL);
//		}
		
		return answer;
	}
}
